#include <bits/stdc++.h>
using namespace std;

const int N = 3e4 + 10;

char offset = '0';
int tr[N][2], fail[N], ed[N], idx;

vector<int> g[N];
int in_deg[N];

void insert(const string& s)
{
    int p = 0;
    for (char it : s) {
        int c = it - offset;
        if (tr[p][c] == 0) tr[p][c] = ++idx;
        p = tr[p][c];
    }
    ed[p] = 1;
}

void setfail()
{
    queue<int> q;
    for (int i = 0; i < 2; i++)
        if (tr[0][i]) q.push(tr[0][i]);

    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = 0; i < 2; i++) {
            int& v = tr[u][i];
            if (v) {
                fail[v] = tr[fail[u]][i];
                ed[v] |= ed[fail[v]]; // 继承终止状态
                q.push(v);
            } else {
                v = tr[fail[u]][i]; // 完成转移
            }
        }
    }
}

bool check_cycle()
{
    int cnt = 0;
    for (int u = 0; u <= idx; u++) {
        if (ed[u]) continue;
        cnt++;
        for (int c = 0; c < 2; c++) {
            int v = tr[u][c];
            if (!ed[v]) {
                g[u].push_back(v);
                in_deg[v]++;
            }
        }
    }


    queue<int> q;
    for (int i = 0; i <= idx; i++)
        if (!ed[i] && in_deg[i] == 0)
            q.push(i);

    while (!q.empty()) {
        int u = q.front(); q.pop();
        cnt--;
        for (int v : g[u]) {
            if (--in_deg[v] == 0) {
                q.push(v);
            }
        }
    }
    return cnt != 0;
}

void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        insert(s);
    }

    setfail();

    if (check_cycle()) cout << "TAK\n";
    else cout << "NIE\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}
